﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MoAds.CustomAdServiceSite.Models
{
    public class AdInfo
    {
        public long Id { get; set; }
        public string ImageUrl { get; set; }
        public string AdText { get; set; }
        public string AdUrl { get; set; }
    }

    public static class AdRepository
    {
        private static List<AdInfo> Ads = new List<AdInfo>()
        {
            // Click Urls are generated from request
            new AdInfo()
            {
                Id = 0,
                ImageUrl = "http://localhost:53339/Content/AdImages/Ad0.png",
                AdText = "Custom Ad 0",               
                AdUrl = "http://jacob4u2.blogspot.com"
            },
            new AdInfo()
            {
                Id = 1,
                ImageUrl = "http://localhost:53339/Content/AdImages/Ad1.png",
                AdText = "Custom Ad 1",                
                AdUrl = "http://jacob4u2.blogspot.com"
            },
            new AdInfo()
            {
                Id = 2,
                ImageUrl = "http://localhost:53339/Content/AdImages/Ad2.png",
                AdText = "Custom Ad 2",                
                AdUrl = "http://jacob4u2.blogspot.com"
            },
            new AdInfo()
            {
                Id = 3,
                ImageUrl = "http://localhost:53339/Content/AdImages/Ad3.png",
                AdText = "Custom Ad 3",  
                AdUrl = "http://jacob4u2.blogspot.com"
            },
            new AdInfo()
            {
                Id = 4,
                ImageUrl = "http://localhost:53339/Content/AdImages/Ad4.png",
                AdText = "Custom Ad 4",               
                AdUrl = "http://jacob4u2.blogspot.com"
            },
            new AdInfo()
            {
                Id = 5,
                ImageUrl = "http://localhost:53339/Content/AdImages/Ad5.png",
                AdText = "Custom Ad 5",               
                AdUrl = "http://jacob4u2.blogspot.com"
            },
        };

        public static AdInfo GetRandomAd()
        {
            Random rnd = new Random();
            Int32 id = rnd.Next(0, 5);
            return GetAdById(id);
        }

        public static AdInfo GetAdById(long id)
        {
            return Ads.FirstOrDefault(x => x.Id == id);
        }
    }
}